<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\publics\controller;

class AdminTmpl extends \app\AdminRest
{
    protected $model;
    public function __construct(\think\App $app)
    {
        parent::__construct($app);
        $this->model = new \app\publics\model\TmplConfig();
    }
    public function getTmplId()
    {
        $input = $this->_input;
        $service_model = new \longbingcore\wxcore\WxTmpl($this->_uniacid);
        $dis["id"] = $input["id"];
        $tmpl_data = $service_model::addtmpl($dis);
        if(isset($tmpl_data["errcode"]) && $tmpl_data["errcode"] == 0) {
            $this->model->tmplUpdate($dis, ["tmpl_id" => $tmpl_data["priTmplId"]]);
            return $this->success($tmpl_data["priTmplId"]);
        }
        return $this->error($tmpl_data["errmsg"]);
    }
    public function tmpList()
    {
        $input = $this->_input;
        $tmpl_data = [];
        if(isset($input["model_name"])) {
            $tmpl_data = \app\publics\service\PublicsService::getTmplByModelName($this->_uniacid, $input["model_name"]);
        }
        return $this->success($tmpl_data);
    }
    public function tmpLists()
    {
        $authModelList = \longbingcore\permissions\AdminMenu::getAuthList($this->_uniacid);
        $tmpl_data = [];
        foreach ($authModelList as $key => $item) {
            $modelTmplData = \app\publics\service\PublicsService::getTmplByModelName($this->_uniacid, $key);
            $tmpl_data = array_merge($tmpl_data, $modelTmplData);
        }
        return $this->success($tmpl_data);
    }
    public function tmplUpdate()
    {
        $input = $this->_input;
        if(!empty($input) && is_array($input)) {
            foreach ($input as $value) {
                $res = $this->model->tmplUpdate(["id" => $value["id"]], ["tmpl_id" => $value["tmpl_id"], "kidList" => $value["kidList"]]);
            }
            return $this->success($res);
        } else {
            return $this->error("参数错误");
        }
    }
}

?>